<!DOCTYPE html PUBLIC "-//W3C//Dtd XHTML 1.0 Transitional//EN" "http://www.w3.org/tr/xhtml1/Dtd/xhtml1-transitional.dtd">
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="com.infodms.dms.common.Constant" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<%@taglib uri="/jstl/cout" prefix="c" %>
<jsp:include page="${contextPath}/common/jsp_head_new.jsp" />
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>物料组维护</title>
</head>
<body>
<div class="navigation"><img src="<%=request.getContextPath()%>/img/nav.gif" />&nbsp;当前位置：系统管理 > 产品维护 > 物料组维护</div>
<form method="POST" name="fm" id="fm">
  	<table class="table_query" border="0">
		<tr>
		    <td class="table_query_2Col_label_8Letter" nowrap="nowrap">物料组代码：</td>
		    <td class="table_query_4Col_input" nowrap="nowrap">
		    	<input name="groupCode" datatype="0,is_null,30" id="groupCode" type="text" class="middle_txt" value="${po.groupCode}"/>
		    </td>
		    <td class="table_query_2Col_label_8Letter" nowrap="nowrap">物料组名称：</td>
		    <td class="table_query_2Col_input" nowrap="nowrap">
		    	<input name="groupName" datatype="0,is_null,30" id="groupCode" type="text" class="middle_txt" value="${po.groupName}"/>
		    </td>
		</tr>
		<tr>
		    <td class="table_query_2Col_label_8Letter" nowrap="nowrap">上级物料组：</td>
		    <td class="table_query_2Col_input" nowrap="nowrap">
		    	<input type="text" class="middle_txt" name="parentGroupCode" id="parentGroupCode" readonly="readonly" value="${po.groupLevel == 1 ? '' : parent.groupCode}" onpropertychange="getModelGroup(this.value);"/>
				<input name="button3" type="button" class="mini_btn" onclick="showMaterialGroup('parentGroupCode','','false','','true')" value="..." />
				<input class="normal_btn" type="button" value="清空" onclick="clrTxt('parentGroupCode');"/>
		    </td>
		    <td class="table_query_2Col_label_8Letter" nowrap="nowrap">物料状态：</td>
		    <td class="table_query_2Col_input" nowrap="nowrap">
		    	<script type="text/javascript">
			      	genSelBoxExp("status",<%=Constant.STATUS%>,"${po.status}",false,"short_sel","","false",'');
			    </script>
		    </td>
		</tr>
		<tr>
		  <td class="table_query_2Col_label_8Letter" nowrap="nowrap">是否可预测：</td>
		    <td class="table_query_2Col_input" nowrap="nowrap">
		    <c:if  test="${po.forcastFlag==1}">
		    	<script type="text/javascript">
			      	genSelBoxExp("ifType",<%=Constant.IF_TYPE%>,"<%=Constant.IF_TYPE_YES%>",false,"short_sel","","false",'');
			    </script>
			    </c:if>
			     <c:if  test="${po.forcastFlag==0}">
		    	<script type="text/javascript">
			      	genSelBoxExp("ifType",<%=Constant.IF_TYPE%>,"<%=Constant.IF_TYPE_NO%>",false,"short_sel","","false",'');
			    </script>
			    </c:if>
		    </td>
		</tr>
		<tr id="trObj" style="display:${po.groupLevel == 3 ? 'inline': 'none'}">
		    <td class="table_query_2Col_label_8Letter" nowrap="nowrap">售后车型组：</td>
		    <td class="table_query_2Col_input" nowrap="nowrap">
		    	<select name="modelGroup1">
		    		<c:forEach items="${groups1}" var="po">
						<option value="${po.WRGROUP_ID}">${po.WRGROUP_NAME}</option>
					</c:forEach>
		        </select>
		    </td>
		    <td class="table_query_2Col_label_8Letter" nowrap="nowrap">销售车型组：</td>
		    <td class="table_query_2Col_input" nowrap="nowrap">
		    	<select name="modelGroup2">
		    		<c:forEach items="${groups2}" var="po">
						<option value="${po.WRGROUP_ID}">${po.WRGROUP_NAME}</option>
					</c:forEach>
		        </select>
		    </td>
		  </tr>
		<tr>
		    <td colspan="4" align="center">
		    	<input type="hidden" name="groupId" value="${po.groupId}">
		    	<input name="button2" type="button" class="normal_btn" onclick="confirmAdd();" value="保存"/>
		      	<input name="button" type="button" class="normal_btn" onclick="history.back();" value="返回"/>
		    </td>
	  	</tr>
	</table>
</form>
<script type="text/javascript">
	function doInit(){
		if(${po.groupLevel == 3}){
			document.getElementById("modelGroup1").value = '${group1.WRGROUP_ID}';
			document.getElementById("modelGroup2").value = '${group2.WRGROUP_ID}';
		}
	}
	
	function confirmAdd(){
		if(submitForm('fm')){
			MyConfirm("是否确认保存?",addSave);
		}
	}
	
	function addSave(){
		makeNomalFormCall('<%=request.getContextPath()%>/sysproduct/productmanage/MaterialGroupManage/materialGroupManageMod.json',showResult,'fm');
	}
	
	function showResult(json){
		if(json.returnValue == '1'){
			window.location.href = '<%=request.getContextPath()%>/sysproduct/productmanage/MaterialGroupManage/materialGroupManageQueryPre.do';
		}else{
			MyAlert("新增失败！请联系系统管理员！");
		}
	}
	
	function clrTxt(txtId){ 
    	document.getElementById(txtId).value = "";
    	getModelGroup('clear');
    }
    
    function getModelGroup(arg){	
   		if (event.propertyName == "value"){
    		var url = "<%=request.getContextPath()%>/sysproduct/productmanage/MaterialGroupManage/getModelGroup.json";
			makeCall(url,showModelGroup,{groupCode:arg}); 
    	}	
	}
	
	function showModelGroup(json){
		var trObj = document.getElementById("trObj");
		if(json.returnValue == '1'){
			trObj.style.display = "inline";
		}
		else{
			trObj.style.display = "none";
		}
	}
</script>
</body>
</html>
